﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SharpShare.Storage.Searching.Parameters {
    public abstract class RangeSearchParameter<T> : SearchParameter where T : IComparable {
        protected RangeSearchParameter(T minimum, T maximum) {
            this.Minimum = minimum;
            this.Maximum = maximum;
        }

        public T Minimum { get; private set; }
        public T Maximum { get; private set; }

        protected abstract T GetMatchValue(IStorageItem item);

        public override bool Matches(IStorageItem item) {
            T value = GetMatchValue(item);

            bool match = (value.CompareTo(this.Minimum) > 0 && value.CompareTo(this.Maximum) < 0);

            return match;
        }
    }
}
